home *** CD-ROM | disk | FTP | other *** search
/ Atari Forever 4 / Atari Forever 4.zip / Atari Forever 4.iso / PD_THEMA / EDITOREN / 7UP_PD / FONTSEL4.C < prev    next >
C/C++ Source or Header  |  1998-03-14  |  20KB  |  806 lines

  1. /* Fontauswahlbox */
  2. /*****************************************************************************
  3. *
  4. *                                              7UP
  5. *                                        Modul: FONTSEL.C
  6. *                                     (c) by TheoSoft '90
  7. *
  8. *****************************************************************************/
  9. #include <portab.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <aes.h>
  14. #include <vdi.h>
  15.  
  16. #include "alert.h"
  17.  
  18. #include "forms.h"
  19. #include "windows.h"
  20. #include "7up.h"
  21.  
  22. #define MAXENTRIES     5
  23. #define MAXLETTERS    32
  24. #define MAXSPACES     18
  25. #define POINT_MAX  32767
  26. #define notnull(a) (((a)>0)?(a):(1))
  27. #define VEKTOR_KENNZEICHEN 250
  28.  
  29. #define MONO 1
  30. #define FLAGS15 0x8000
  31.  
  32. int additional=0;
  33.  
  34. int tid,tsize,tattr; /* topId, topSize, topAttr */
  35. extern WINDOW *twp; /* Topwindowpointer */
  36. extern char alertstr[256];
  37. extern int boxh;
  38.  
  39. static int propfonts=FALSE;
  40.  
  41. long *get_cookie(long cookie);
  42. /*
  43. void objc_update(OBJECT *tree, int obj, int depth)
  44. {
  45.     int obx,oby;
  46.     objc_offset(tree,obj,&obx,&oby);
  47.     if(obj==ROOT) /* 3 Pixel Rand beachten */
  48.         objc_draw(tree,obj,depth,obx-3,oby-3,
  49.             tree[obj].ob_width+6,tree[obj].ob_height+6);
  50.     else
  51.         objc_draw(tree,obj,depth,obx,oby,
  52.             tree[obj].ob_width,tree[obj].ob_height);
  53. }
  54. */
  55. void objc_update(OBJECT *tree, int obj, int depth)
  56. {
  57.     int obx,oby;
  58.     int full[4],area[4],array[4];
  59.     extern int windials, dial_handle;
  60.         
  61.     objc_offset(tree,obj,&array[0],&array[1]);
  62.     if(obj==ROOT) /* 3 Pixel Rand beachten */
  63.     {
  64.         array[0]-=3;
  65.         array[1]-=3;
  66.         array[2]=tree[obj].ob_width+6;
  67.         array[3]=tree[obj].ob_height+6;
  68.     }
  69.     else
  70.     {
  71.         array[2]=tree[obj].ob_width;
  72.         array[3]=tree[obj].ob_height;
  73.     }
  74.     if(windials && dial_handle!=-1 && !(tree->ob_flags & FLAGS15))
  75.     {
  76.         wind_update(BEG_UPDATE);
  77.         _wind_get( 0, WF_WORKXYWH,  &full[0], &full[1], &full[2], &full[3]);
  78.         _wind_get(dial_handle, WF_FIRSTXYWH, &area[0], &area[1], &area[2], &area[3]);
  79.         while( area[2] && area[3] )
  80.         {
  81.             if(rc_intersect(full,area))
  82.                 if(rc_intersect(array,area))
  83.                     objc_draw(tree,obj,depth,area[0],area[1],area[2],area[3]);
  84.             _wind_get(dial_handle, WF_NEXTXYWH,&area[0],&area[1],&area[2],&area[3]);
  85.         }
  86.         wind_update(END_UPDATE);
  87.     }
  88.     else
  89.     {
  90.         objc_draw(tree,obj,depth,array[0],array[1],array[2],array[3]);
  91.     }
  92. }
  93.  
  94. void set_vslider(OBJECT *tree, int ext, int slide,  int newpos)
  95. {
  96.     long oldpos;
  97.     oldpos=tree[ext].ob_height-tree[slide].ob_height;
  98.     tree[slide].ob_y=(int)(oldpos*(long)newpos/1000L);
  99. }
  100.  
  101. static void set_hslider(OBJECT *tree, int ext, int slide,  int newpos)
  102. {
  103.     long oldpos;
  104.     oldpos=tree[ext].ob_width-tree[slide].ob_width;
  105.     tree[slide].ob_x=(int)(oldpos*(long)newpos/1000L);
  106. }
  107.  
  108. static int selfontsize(int size, int sizearray[])
  109. {
  110.     register int i;
  111.     for(i=0; sizearray[i]!=-1; i++)
  112.         if(size==sizearray[i])
  113.             return(i);
  114.     for(i=1; sizearray[i]!=-1; i++)
  115.         if(size>sizearray[i-1] && size<sizearray[i])
  116.         {
  117.             if(abs(size-sizearray[i-1]) < abs(size-sizearray[i]))
  118.                 return(i-1);
  119.             else
  120.                 return(i);
  121.         }
  122.     return(0);
  123. }
  124.  
  125. static int isprop(int handle, int id)
  126. {
  127.     int ret, width, tst_width, dummy;
  128.  
  129.     if(propfonts)
  130.         return(FALSE);
  131.     
  132.     vst_point(handle,10,&ret,&ret,&ret,&ret);
  133.     vqt_width(handle, 'l', &width, &dummy, &dummy);        /* Breite 1. Zeichen */
  134.     vqt_width(handle, 'W', &tst_width, &dummy, &dummy);  /* Breite 2. Zeichen */
  135.     if (tst_width != width)                        /* Ungleich? */
  136.         return(TRUE);                                 /* Ja -> Font ist proportional */
  137.     return(FALSE);        /* Alle Zeichen gleich breit -> Font ist monospaced */
  138. }
  139.  
  140. static void fsreverse(int *a, int *b, int cnt)
  141. {
  142.     register int i;
  143.     for(i=cnt; i>0; i--)
  144.         *a++ = *b--;
  145. }
  146.  
  147. static int scan_font_names(int handle, FONTINFO *font, int add, int ftype)
  148. {
  149.     FONTINFO *fip;
  150.     int id,i,j,k,m,ret,vektor;
  151.     char *cp,name[64];
  152.     int prop=0,fstemp[MAXSIZES+1];
  153.  
  154.     for(i=1,m=0; i<=add; i++)
  155.     {
  156.         memset(name,0,sizeof(name));
  157.         id=vqt_name(handle,i,name);
  158.         vektor=name[32];
  159.         name[32]=0;
  160.       if(stricmp(name,"dummy font"))
  161.       {
  162.             vst_font(handle,id);
  163.             if(ftype && isprop(handle, id))
  164.             {
  165.                 prop++;
  166.             }
  167.             else
  168.             {
  169.                 fip=&font[m++];
  170.                 strcpy(fip->name,name);
  171.                 /* mehrfache Blanks killen */
  172.                 cp=strchr(fip->name,' ');
  173.                 while(cp)
  174.                 {
  175.                     if(*(cp+1L) == ' ')
  176.                         strcpy(cp,cp+1L);
  177.                     cp=strchr((*(cp+1L)==' '?cp:cp+1L),' ');
  178.                 }
  179.                 fip->id=id;
  180.                 fip->attr=vektor;
  181.                 fstemp[0]=-1;
  182.                 for(j=POINT_MAX,k=1; j>0 && k<=MAXSIZES; /* nix */)
  183.                 {
  184.                     fstemp[k]=j=vst_point(handle,j,&ret,&ret,&ret,&ret);
  185.                     if(fstemp[k]==fstemp[k-1])
  186.                         break;
  187.                     else
  188.                       j--,k++;
  189.                 }
  190.                 fsreverse(fip->size,&fstemp[k-1],k);
  191.             }
  192.         }
  193.     }
  194.     return(add-prop);
  195. }
  196. /*
  197. static void Three_D_Look(OBJECT *tree, int obj)
  198. {
  199.     tree[obj].ob_flags|=0x0200;
  200.     tree[obj].ob_flags|=0x0400;
  201.     tree[obj].ob_x+=2;
  202.     tree[obj].ob_y+=2;
  203.     tree[obj].ob_width-=4;
  204.     tree[obj].ob_height-=4;
  205. }
  206. */
  207. int fontsel_input(OBJECT *tree, int handle, int fontid, int fontsize, int ncount, int ftype, int *id, int *size)
  208. {
  209.     static FONTINFO *fip;
  210.     static long nf2=0,sf2=0;
  211.  
  212.     FONTINFO *font;
  213.     long nfirst,sfirst,hfirst,newpos=0;
  214.     int scount,kstate,exit_obj,done=FALSE;
  215.     int i,k,ret,mx,my;
  216.     int obx,oby;
  217.  
  218.     char string[34];
  219.  
  220.     graf_mkstate(&ret,&ret,&ret,&kstate); /* geheim, bei CTRL wird alles angezeigt */
  221.     if(kstate & K_CTRL)
  222.         propfonts=TRUE;
  223.  
  224.     if((font=(FONTINFO *)calloc(ncount,sizeof(FONTINFO)))==NULL)
  225.     {
  226.         return(-1); /* Fehler! */
  227.     }
  228.     ncount=scan_font_names(handle, font, ncount, ftype);
  229.  
  230.     /* Fontnamenslidergröße ändert sich nie */
  231.     tree[FTHSLD].ob_width=MAXSPACES*tree[FTHBOX].ob_width/MAXLETTERS;
  232.     set_hslider(tree,FTHBOX,FTHSLD,0);
  233.     tree[FTSLIDE].ob_height=
  234.          MAXENTRIES*tree[FTBOX].ob_height/max(MAXENTRIES,ncount);
  235.     
  236.     /* MT 2.11.94 */
  237.     tree[FTSLIDE].ob_height=max(boxh,tree[FTSLIDE].ob_height);
  238.     
  239.     set_vslider(tree,FTBOX,FTSLIDE,0);
  240.  
  241. /**************************************************************************/
  242. /* letzte OK-Werte einstellen, falls verstellt und Abbruch gedrückt wurde */
  243. /**************************************************************************/
  244.     nfirst=nf2;
  245.     sfirst=sf2;
  246.     hfirst=0;
  247.  
  248.     for(i=nfirst; i<ncount /*&& i<MAXFONTS*/; i++) /* erstmal suchen,... */
  249.         if(font[i].id==fontid)                  /* falls nicht in Box */
  250.         {
  251.             fip=&font[i];
  252.             if((i-nfirst)>MAXENTRIES)
  253.                 nf2=nfirst=(i-MAXENTRIES+1);
  254.         }
  255.  
  256.     /* Namenseinstellung */
  257.     for(i=FTYPE1; i<=FTYPE5; i++)
  258.     {
  259.         tree[i].ob_state&=~SELECTED;
  260.         tree[i].ob_flags&=~SELECTABLE;
  261.     }
  262.     /* falscher (int) cast */
  263.     newpos=/*(int)*/(nfirst*1000L)/notnull(ncount-MAXENTRIES);
  264.     newpos=min(newpos,1000);
  265.     newpos=max(0,newpos);
  266.     set_vslider(tree,FTBOX,FTSLIDE,newpos);
  267.     newpos=/*(int)*/(hfirst*1000L)/(MAXLETTERS-MAXSPACES);
  268.     newpos=min(newpos,1000);
  269.     newpos=max(0,newpos);
  270.     set_hslider(tree,FTHBOX,FTHSLD,newpos);
  271.     for(i=nfirst,k=0; i<ncount /*&& i<MAXFONTS*/ && k<MAXENTRIES; i++,k++)
  272.     {
  273.         sprintf(string," %-16s ",&font[i].name[hfirst]);
  274.         /* MT 5.11.94 Vektorfonts kennzeichnen */
  275.         if(font[i].attr) string[0]=VEKTOR_KENNZEICHEN;
  276.         
  277.         string[MAXSPACES]=0;
  278.         form_write(tree,FTYPE1+k,string,FALSE);
  279.         tree[FTYPE1+k].ob_flags|=SELECTABLE;
  280.         if(font[i].id==fontid)
  281.         {
  282.             tree[FTYPE1+k].ob_state|=SELECTED;
  283.             fip=&font[i];
  284.         }
  285.     }
  286.     for(; k<MAXENTRIES; k++)
  287.     {
  288.         memset(string,' ',MAXLETTERS);
  289.         string[MAXLETTERS]=0;
  290.         form_write(tree,FTYPE1+k,string,FALSE);
  291.     }
  292.  
  293.     /* Punkteinstellung */
  294.     for(i=FSIZE1; i<=FSIZE5; i++)
  295.     {
  296.         form_write(tree,i,"",FALSE);
  297.         tree[i].ob_state&=~SELECTED;
  298.         tree[i].ob_flags&=~SELECTABLE;
  299.     }
  300.     for(scount=0; fip->size[scount]!=-1; scount++)
  301.         ;
  302.     for(i=sfirst; i<scount && i<MAXSIZES; i++) /* erstmal suchen,... */
  303.         if(fip->size[i]==fontsize)                  /* falls nicht in Box */
  304.         {
  305.             if((i-sfirst)>MAXENTRIES)
  306.                 sf2=sfirst=(i-MAXENTRIES+1);
  307.         }
  308.     tree[FSSLIDE].ob_height=MAXENTRIES*tree[FSBOX].ob_height/max(MAXENTRIES,scount);
  309.  
  310.     /* MT 2.11.94 */
  311.     tree[FSSLIDE].ob_height=max(boxh,tree[FSSLIDE].ob_height);
  312.  
  313.    newpos=/*(int)*/(sfirst*1000L)/notnull(scount-MAXENTRIES);
  314.     newpos=min(newpos,1000);
  315.     newpos=max(0,newpos);
  316.     set_vslider(tree,FSBOX,FSSLIDE,newpos);
  317.  
  318.     for(i=sfirst,k=0; i<MAXSIZES && k<MAXENTRIES && i<scount; i++,k++)
  319.     {
  320.         sprintf(tree[FSIZE1+k].ob_spec.tedinfo->te_ptext," %3d ",fip->size[i]);
  321.         tree[FSIZE1+k].ob_flags|=SELECTABLE;
  322.         if(fip->size[i]==fontsize)
  323.         {
  324.             tree[FSIZE1+k].ob_state|=SELECTED;
  325.          sprintf(string,"%3d",fontsize);
  326.          form_write(tree,FSARBPT,string,FALSE);
  327.         }
  328.     }
  329. /**************************************************************************/
  330.     tid=*id=fontid,tsize=*size=fontsize,tattr=fip?fip->attr:0;
  331. /*
  332.     if(_GemParBlk.global[0] >=0x0340) /* Ab Falcon Muster ändern */
  333.     {
  334.         tree[FNTITLE].ob_spec.tedinfo->te_color&=~(7<<4); /* löschen */
  335.         tree[FNTITLE].ob_spec.tedinfo->te_color|=(4<<4);  /* neues Muster 4 */
  336.         tree[FSTITLE].ob_spec.tedinfo->te_color&=~(7<<4); /* löschen */
  337.         tree[FSTITLE].ob_spec.tedinfo->te_color|=(4<<4);  /* neues Muster 4 */
  338.         tree[FTBOX  ].ob_spec.obspec.fillpattern=4;
  339.         tree[FTHBOX ].ob_spec.obspec.fillpattern=4;
  340.         tree[FSBOX  ].ob_spec.obspec.fillpattern=4;
  341.     }
  342. */
  343.    if(vq_vgdos()==0x5F46534D) /* Vektor-GDOS */
  344.    {
  345.       tree[FSARBPT].ob_flags&=~HIDETREE;
  346.       tree[FSARBPT].ob_flags|=EDITABLE;
  347.    }
  348.     else
  349.     {
  350.       tree[FSARBPT].ob_flags|=HIDETREE;
  351.       tree[FSARBPT].ob_flags&=~EDITABLE;
  352.    }
  353.     form_exopen(tree,0);
  354.     do
  355.     {
  356.         exit_obj=form_exdo(tree,0);
  357.         graf_mkstate(&mx,&my,&ret,&kstate);
  358.         switch(exit_obj)
  359.         {
  360.             case FTLF:
  361.                 if(hfirst>0)
  362.                     hfirst--;
  363.                 else
  364.                     exit_obj=-1;  /* löschen */
  365.                 break;
  366.             case FTRT:
  367.                 if(hfirst<(MAXLETTERS-MAXSPACES)) /* MAXSPACES+8=MAXLETTERS */
  368.                     hfirst++;
  369.                 else
  370.                     exit_obj=-1;
  371.                 break;
  372.          case FTUP:
  373.                 if(kstate & (K_LSHIFT|K_RSHIFT))
  374.                 {
  375.                     if((nfirst-MAXENTRIES)>0)
  376.                         nfirst-=MAXENTRIES;
  377.                     else
  378.                         nfirst=0;
  379.                 }
  380.                 else
  381.                 {
  382.                 if(nfirst>0)
  383.                    nfirst--;
  384.                 else
  385.                    exit_obj=-1;
  386.              }
  387.             break;
  388.          case FTDN:
  389.                 if(kstate & (K_LSHIFT|K_RSHIFT))
  390.                 {
  391.                     if((nfirst+MAXENTRIES)<(ncount-MAXENTRIES))
  392.                         nfirst+=MAXENTRIES;
  393.                     else
  394.                         nfirst=ncount-MAXENTRIES;
  395.                 }
  396.                 else
  397.                 {
  398.                 if(nfirst<ncount-MAXENTRIES)
  399.                    nfirst++;
  400.                 else
  401.                    exit_obj=-1;
  402.              }
  403.             break;
  404.             case FSUP:
  405.                 if(sfirst>0)
  406.                     sfirst--;
  407.                 else
  408.                     exit_obj=-1;
  409.                 break;
  410.             case FSDN:
  411.                 if(sfirst<scount-MAXENTRIES)
  412.                     sfirst++;
  413.                 else
  414.                     exit_obj=-1;
  415.                 break;
  416.             case FTHSLD:
  417.                 graf_mouse(FLAT_HAND,NULL);
  418.                 newpos=graf_slidebox(tree,FTHBOX,FTHSLD,0);
  419.                 graf_mouse(ARROW,NULL);
  420.                 hfirst=((newpos*(MAXLETTERS-MAXSPACES))/1000L);
  421.                 break;
  422.             case FTSLIDE:
  423.                 graf_mouse(FLAT_HAND,NULL);
  424.                 newpos=graf_slidebox(tree,FTBOX,FTSLIDE,1);
  425.                 graf_mouse(ARROW,NULL);
  426.                 nfirst=((newpos*(ncount-MAXENTRIES))/1000L);
  427.                 break;
  428.             case FSSLIDE:
  429.                 graf_mouse(FLAT_HAND,NULL);
  430.                 newpos=graf_slidebox(tree,FSBOX,FSSLIDE,1);
  431.                 graf_mouse(ARROW,NULL);
  432.                 sfirst=((newpos*(scount-MAXENTRIES))/1000L);
  433.                 break;
  434.             case FTHBOX:
  435.                 objc_offset(tree,FTHSLD,&obx,&oby);
  436.                 if(mx>obx)
  437.                 {
  438.                     if((hfirst+MAXSPACES)<(MAXLETTERS-MAXSPACES))
  439.                         hfirst+=MAXSPACES;
  440.                     else
  441.                         hfirst=MAXLETTERS-MAXSPACES;
  442.                 }
  443.                 else
  444.                 {
  445.                     if((hfirst-MAXSPACES)>0)
  446.                         hfirst-=MAXSPACES;
  447.                     else
  448.                         hfirst=0;
  449.                 }
  450.                 break;
  451.             case FTBOX:
  452.                 objc_offset(tree,FTSLIDE,&obx,&oby);
  453.                 if(my>oby)
  454.                 {
  455.                     if((nfirst+MAXENTRIES)<(ncount-MAXENTRIES))
  456.                         nfirst+=MAXENTRIES;
  457.                     else
  458.                         nfirst=ncount-MAXENTRIES;
  459.                 }
  460.                 else
  461.                 {
  462.                     if((nfirst-MAXENTRIES)>0)
  463.                         nfirst-=MAXENTRIES;
  464.                     else
  465.                         nfirst=0;
  466.                 }
  467.                 break;
  468.             case FSBOX:
  469.                 objc_offset(tree,FSSLIDE,&obx,&oby);
  470.                 if(my>oby)
  471.                 {
  472.                     if((sfirst+MAXENTRIES)<(scount-MAXENTRIES))
  473.                         sfirst+=MAXENTRIES;
  474.                     else
  475.                         sfirst=scount-MAXENTRIES;
  476.                 }
  477.                 else
  478.                 {
  479.                     if((sfirst-MAXENTRIES)>0)
  480.                         sfirst-=MAXENTRIES;
  481.                     else
  482.                         sfirst=0;
  483.                 }
  484.                 break;
  485.             case FTYPE1:
  486.             case FTYPE1+1:
  487.             case FTYPE1+2:
  488.             case FTYPE1+3:
  489.             case FTYPE1+4:
  490.             case FTYPE1+5:
  491.                 if(tree[exit_obj].ob_flags & SELECTABLE &&
  492.                  !(tree[exit_obj].ob_state & DISABLED))
  493.                 {
  494.                     for(i=FSIZE1; i<=FSIZE5; i++)
  495.                     {
  496.                         tree[i].ob_state &= ~SELECTED;
  497.                         tree[i].ob_flags &= ~SELECTABLE;
  498.                     }
  499.                     fip=&font[exit_obj-FTYPE1+nfirst];
  500.                     *id=fip->id;
  501.                     for(scount=0; fip->size[scount]!=-1; scount++)
  502.                         ;
  503.                     tree[FSSLIDE].ob_height=
  504.                         MAXENTRIES*tree[FSBOX].ob_height/max(MAXENTRIES,scount);
  505.                     
  506.                     /* MT 2.11.94 */
  507.                     tree[FSSLIDE].ob_height=max(boxh,tree[FSSLIDE].ob_height);
  508.                     
  509.                     set_vslider(tree,FSBOX,FSSLIDE,0);
  510.                     objc_update(tree,FSBOX,MAX_DEPTH);
  511.                     k=selfontsize(fontsize,fip->size);
  512.                     *size=fip->size[k];
  513.                     for(i=0; i<=(FSIZE5-FSIZE1)  && fip->size[i]!=-1; i++)
  514.                     {
  515.                         tree[FSIZE1+i].ob_flags |= SELECTABLE;
  516.                         sprintf(tree[FSIZE1+i].ob_spec.tedinfo->te_ptext,
  517.                             " %3d ",fip->size[i]);
  518.                         if(k==i) /* Fontsize == Eintrag? */
  519.                         {
  520.                             tree[FSIZE1+i].ob_state |= SELECTED;
  521.                          sprintf(string,"%3d",fip->size[i]);
  522.                          form_write(tree,FSARBPT,string,TRUE);
  523.                         }
  524.                         objc_update(tree,FSIZE1+i,0);
  525.                     }
  526.                     for(; i<=(FSIZE5-FSIZE1); i++)
  527.                         form_write(tree,FSIZE1+i,"     ",TRUE);
  528.                     sfirst=0;
  529.                 }
  530.                 break;
  531.             case FSHELP:
  532.                 form_alert(1,Afontsel[0]);
  533.                 objc_change(tree,exit_obj,0,tree->ob_x,tree->ob_y,tree->ob_width,tree->ob_height,tree[exit_obj].ob_state&~SELECTED,TRUE);
  534.                 break;
  535.             case FSOK:
  536.             case FSABBR:
  537.                 done=TRUE;
  538.                 break;
  539.         }
  540.         if(exit_obj&0x8000) /* verlassen bei Doppelklick */
  541.         {
  542.             switch(exit_obj&=0x7FFF)
  543.             {
  544.                 case FTYPE1:
  545.                 case FTYPE1+1:
  546.                 case FTYPE1+2:
  547.                 case FTYPE1+3:
  548.                 case FTYPE1+4:
  549.                 case FTYPE1+5:
  550.                 case FSIZE1:
  551.                 case FSIZE1+1:
  552.                 case FSIZE1+2:
  553.                 case FSIZE1+3:
  554.                 case FSIZE1+4:
  555.                 case FSIZE1+5:
  556.                     objc_change(tree,FSOK,0,tree->ob_x,tree->ob_y,
  557.                                     tree->ob_width,tree->ob_height,SELECTED,TRUE);
  558.                     done=TRUE;
  559.                     break;
  560.             case FTLF:
  561.                 if(hfirst>0)
  562.                     hfirst=0;
  563.                 else
  564.                     exit_obj=-1;  /* löschen */
  565.                 break;
  566.             case FTRT:
  567.                 if(hfirst<MAXLETTERS-MAXSPACES) /* MAXSPACES+8=MAXLETTERS */
  568.                     hfirst=MAXLETTERS-MAXSPACES;
  569.                 else
  570.                     exit_obj=-1;
  571.                 break;
  572.             case FTUP:
  573.                 if(nfirst>0)
  574.                     nfirst=0;
  575.                 else
  576.                     exit_obj=-1;
  577.                 break;
  578.             case FTDN:
  579.                 if(nfirst<ncount-MAXENTRIES)
  580.                     nfirst=ncount-MAXENTRIES;
  581.                 else
  582.                     exit_obj=-1;
  583.                 break;
  584.             case FSUP:
  585.                 if(sfirst>0)
  586.                     sfirst=0;
  587.                 else
  588.                     exit_obj=-1;
  589.                 break;
  590.             case FSDN:
  591.                 if(sfirst<scount-MAXENTRIES)
  592.                     sfirst=scount-MAXENTRIES;
  593.                 else
  594.                     exit_obj=-1;
  595.                 break;
  596.             case FSSHOW:
  597.          case FSARBPT:
  598.              form_read(tree,FSARBPT,string);
  599.               if(*size!=atoi(string))
  600.               {
  601.                  *size=atoi(string);
  602.                     tid=*id,tsize=*size,tattr=fip?fip->attr:0;
  603.                     objc_update(tree,FSSHOW,0);
  604.                 }
  605.             break;
  606.             }
  607.         }
  608.         switch(exit_obj)
  609.         {
  610.             case FTLF:
  611.             case FTRT:
  612.             case FTHBOX:
  613.             case FTHSLD:
  614.                 newpos=/*(int)*/(hfirst*1000L)/(MAXLETTERS-MAXSPACES);
  615.                 newpos=min(max(0,newpos),1000);
  616.                 set_hslider(tree,FTHBOX,FTHSLD,newpos);
  617.                 objc_update(tree,FTHBOX,MAX_DEPTH);
  618.                 for(i=nfirst,k=0; /*i<MAXFONTS &&*/ k<MAXENTRIES && k<ncount; i++,k++)
  619.                 {
  620.                     sprintf(string," %-16s ",&font[i].name[hfirst]);
  621.                     /* MT 5.11.94 Vektorfonts kennzeichnen */
  622.                     if(font[i].attr) string[0]=VEKTOR_KENNZEICHEN;
  623.                     string[MAXSPACES]=0;
  624.                     form_write(tree,FTYPE1+k,string,TRUE);
  625.                 }
  626.                 break;
  627.             case FTUP:
  628.             case FTDN:
  629.             case FTBOX:
  630.             case FTSLIDE:
  631.                 if(ncount>MAXENTRIES)
  632.                 {
  633.                     for(i=FTYPE1; i<=FTYPE5; i++)
  634.                         tree[i].ob_state&=~SELECTED;
  635.                     newpos=/*(int)*/(nfirst*1000L)/notnull(ncount-MAXENTRIES);
  636.                     newpos=min(max(0,newpos),1000);
  637.                     set_vslider(tree,FTBOX,FTSLIDE,newpos);
  638.                     objc_update(tree,FTBOX,MAX_DEPTH);
  639.                     for(i=nfirst,k=0; /*i<MAXFONTS &&*/ k<MAXENTRIES; i++,k++)
  640.                     {
  641.                         sprintf(string," %-16s ",&font[i].name[hfirst]);
  642.                         /* MT 5.11.94 Vektorfonts kennzeichnen */
  643.                         if(font[i].attr) string[0]=VEKTOR_KENNZEICHEN;
  644.                         string[MAXSPACES]=0;
  645.                         form_write(tree,FTYPE1+k,string,TRUE);
  646.                         if(font[i].id==*id)
  647.                         {
  648.                             tree[FTYPE1+k].ob_state|=SELECTED;
  649.                             objc_update(tree,FTYPE1+k,0);
  650.                         }
  651.                     }
  652.                 }
  653.                 break;
  654.             case FSUP:
  655.             case FSDN:
  656.             case FSBOX:
  657.             case FSSLIDE:
  658.                 if(scount>MAXENTRIES)
  659.                 {
  660.                     for(i=FSIZE1; i<=FSIZE5; i++)
  661.                         tree[i].ob_state&=~SELECTED;
  662.                     newpos=/*(int)*/(sfirst*1000L)/notnull(scount-MAXENTRIES);
  663.                     newpos=min(max(0,newpos),1000);
  664.                     set_vslider(tree,FSBOX,FSSLIDE,newpos);
  665.                     objc_update(tree,FSBOX,MAX_DEPTH);
  666.                     for(i=sfirst,k=0; i<MAXSIZES && k<MAXENTRIES; i++,k++)
  667.                     {
  668.                         if(fip->size[i]==*size)
  669.                         {
  670.                             tree[FSIZE1+k].ob_state|=SELECTED;
  671.                          sprintf(string,"%3d",fip->size[i]);
  672.                          form_write(tree,FSARBPT,string,TRUE);
  673.                         }
  674.                         sprintf(tree[FSIZE1+k].ob_spec.tedinfo->te_ptext,
  675.                             " %3d ",fip->size[i]);
  676.                         objc_update(tree,FSIZE1+k,0);
  677.                     }
  678.                 }
  679.                 break;
  680.         }
  681.         switch(exit_obj)
  682.         {
  683.             case FTYPE1:
  684.             case FTYPE1+1:
  685.             case FTYPE1+2:
  686.             case FTYPE1+3:
  687.             case FTYPE1+4:
  688.             case FTYPE1+5:
  689.             case FSIZE1:
  690.             case FSIZE1+1:
  691.             case FSIZE1+2:
  692.             case FSIZE1+3:
  693.             case FSIZE1+4:
  694.             case FSIZE1+5:
  695.                 for(i=FTYPE1,k=0; i<=FTYPE5; i++,k++)
  696.                     if(tree[i].ob_state & SELECTED)
  697.                     {
  698.                         fip=&font[k+nfirst];
  699.                         *id=fip->id;
  700.                         break;
  701.                     }
  702.                 for(i=FSIZE1,k=0; i<=FSIZE5; i++,k++)
  703.                     if(tree[i].ob_state & SELECTED)
  704.                     {
  705.                         *size=fip->size[k+sfirst];
  706.                         tid=*id,tsize=*size,tattr=fip?fip->attr:0;
  707.                         objc_update(tree,FSSHOW,0);
  708.                      sprintf(string,"%3d",*size);
  709.                      form_write(tree,FSARBPT,string,TRUE);
  710.                     }
  711.                 break;
  712.         }
  713.     }
  714.     while(done!=TRUE);
  715.  
  716.     form_exclose(tree, exit_obj,0);
  717.     tree[FSOK].ob_state&=~SELECTED;
  718.     free(font);
  719.     vst_font(handle,fontid); /* Alten Zustand wieder setzen */
  720.     vst_point(handle,fontsize,&ret,&ret,&ret,&ret);
  721.  
  722.     switch(exit_obj)
  723.     {
  724.         case FTYPE1:
  725.         case FTYPE1+1:
  726.         case FTYPE1+2:
  727.         case FTYPE1+3:
  728.         case FTYPE1+4:
  729.         case FTYPE1+5:
  730.         case FSIZE1:
  731.         case FSIZE1+1:
  732.         case FSIZE1+2:
  733.         case FSIZE1+3:
  734.         case FSIZE1+4:
  735.         case FSIZE1+5:
  736.         case FSOK:
  737.             nf2=nfirst;
  738.             sf2=sfirst;
  739.          form_read(tree,FSARBPT,string);
  740.          if(*size!=atoi(string))
  741.             *size =atoi(string);
  742.             return(TRUE);
  743.     }
  744.     *id=*size=-1;
  745.     return(FALSE);
  746. }
  747.  
  748. void hndl_font(WINDOW *wp, OBJECT *tree)     /* geraete direkt ansprechen */
  749. {
  750.     int id,size,ret,kstate;
  751.     extern int work_out[];
  752.  
  753. #if MSDOS
  754.     void far *l;
  755.     long fsize;
  756. #endif
  757.  
  758.     if(wp)
  759.     {
  760.         if(!(wp->w_state & GEMFONTS))
  761.         {
  762.             graf_mouse(BUSY_BEE,0L);
  763.             vq_extnd(wp->vdihandle,0,work_out);
  764. #if GEMDOS
  765.             if(vq_gdos())
  766.             {
  767.                 additional=vst_load_fonts(wp->vdihandle,0)+work_out[10];
  768.                 wp->w_state|=GEMFONTS;
  769.             }
  770.             else
  771.                 additional=work_out[10]; /* Nur 6x6 system font */
  772. #else
  773.             fsize=farcoreleft()-64*1024L;
  774.             if(fsize>0 && (l=farmalloc(fsize))!=NULL)     /*64*/
  775.             {
  776.                 additional=vst_ex_load_fonts(wp->vdihandle, 0, 4096, 0)+work_out[10]; /*4096*/
  777.                 wp->w_state|=GEMFONTS;
  778.                 farfree(l);
  779.             }
  780.             else
  781.                 additional=work_out[10];
  782. #endif
  783.             graf_mouse(ARROW,0L);
  784.         }
  785.         twp=wp;
  786.         switch(fontsel_input(tree,wp->vdihandle,wp->fontid,wp->fontsize,additional,MONO,&id,&size))
  787.         {
  788.             case TRUE:
  789.                 if(id!=wp->fontid || size!=wp->fontsize)
  790.                     Wnewfont(wp,id,size);
  791.                 graf_mkstate(&ret,&ret,&ret,&kstate);
  792.                 if(kstate & (K_LSHIFT|K_RSHIFT))
  793.                 {
  794.                     sprintf(alertstr,Afontsel[2],id,size);
  795.                     form_alert(1,alertstr);
  796.                 }
  797.                 break;
  798.             case FALSE:
  799.                 break;
  800.             case -1:
  801.                 form_alert(1,Afontsel[1]);
  802.                 break;
  803.         }
  804.     }
  805. }
  806.